import csv
from matplotlib import pyplot as plt
from datetime import datetime
import numpy as np

def Pic(filename):
#将文件名存储在filename中


 with open(filename) as f:
     reader=csv.reader(f)
     header_row=next(reader)

     dates,highs,closes=[],[],[]
     for row in reader:
         current_date=datetime.strptime(row[1],"%Y%m%d")
         dates.append(current_date)
 
         high=float(row[3])
         highs.append(high)
 
         low=float(row[5])
         closes.append(low)
 #根据数据绘制图形
 fig=plt.figure(dpi=128,figsize=(10,6))
 plt.plot(dates,highs,c='red',label='open')
 plt.plot(dates,closes,c='blue',label='close')

 #设置图形格式
 plt.title(filename,fontsize=24)
 plt.xlabel('',fontsize=24)
 fig.autofmt_xdate()
 plt.ylabel('money',fontsize=16)
 plt.tick_params(axis='both',which='major',labelsize=16)
 
 plt.legend()
 plt.show()
Pic('601318.SH-.csv')